//
//  AddressBook.m
//  04- 集合02
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "AddressBook.h"

@implementation AddressBook
- (instancetype)init {
    self = [super init];
    if (self) {
        _mDic = [NSMutableDictionary dictionary];
    }
    return self;
}
- (void)addContact:(Contact *)contact {
    if (contact.name.length > 0 && contact.phoneNum > 0) {
        NSMutableArray *marr = [self.mDic objectForKey:contact.groupName];
        NSLog(@"chenggong:%@",contact.name);
        if (marr == nil) {
            marr = [NSMutableArray array];
            [self.mDic setObject:marr forKey:contact.groupName];
            [marr addObject:contact];
        }else {
            [marr addObject:contact];
        }
    }else {
        NSLog(@"添加失败");
    }
}
-(void)removeContact:(Contact *)contact {
    NSMutableArray *marr = [self.mDic objectForKey:contact.groupName];
    if (marr != nil) {
        [self.mDic setObject:marr forKey:contact.groupName];
        [marr removeAllObjects];
    }else {
        NSLog(@"不存在此分组");
    }
}


@end
